<?php
session_start();
include_once ("../php/connect_mysql.php");
if (isset($_SESSION['username'])){
    $comment = htmlspecialchars($_POST["desc"]);
    $username = $_SESSION['username'];
    $time = date("Y-m-d H:i:s",time());
    $uid = $_SESSION['uid'];
    $uip = $_SERVER["REMOTE_ADDR"]; //获取客户端IP
    $sql = "insert into comment_info(id,comment,time,ip) VALUES('$uid','$comment','$time','$uip');";
    $conn->query($sql);
    header("Location:../../Guestbook/index.php");
}
else{
    echo "<script>alert('请登录后评论！');window.location.href = '../page/login_page.php';</script>";
}

?>
